package com.gcu.admin.controller;

import com.gcu.admin.api.dto.UserAuthDTO;
import com.gcu.admin.service.ISysUserService;
import com.gcu.common.base.result.SysResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * @ system:Mac
 * @ author:lin tingfeng
 * @ data:2023/10/9 08:55
 * @ package_name:com.gcu.admin.controller
 * @ project_name:spring-cloud-security
 * @ desc:
 */
@RestController
@RequestMapping(value = {"/api/v1/users", "/user"})
@Slf4j
@RequiredArgsConstructor
public class UserController {

    private final ISysUserService sysUserService;

    /**
     * 获取用户信息
     */
    @GetMapping("/username/{username}")
    public SysResult<UserAuthDTO> getUserByUsername(@NotBlank(message = "username 不能为空") @PathVariable String username) {
        UserAuthDTO user = sysUserService.getByUsername(username);
        return SysResult.ok(user);
    }

}
